package md.lanjing.com.module_wallet.contact;

import android.content.Context;


import com.lxh.baselibray.base.BaseResponce;
import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;
;
import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_wallet.api.WalletApiService;
import md.lanjing.com.module_wallet.bean.HashChargeRequest;
import retrofit2.Call;
import retrofit2.Response;

public class HashChargeContact {
    public static class HashChargePresent extends BasePresent<IHashChargeView> {
        public void hashCharge(final Context context, String hashCode, String type){
            WalletApiService service= ServiceGenerator.createService(WalletApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            HashChargeRequest request=new HashChargeRequest(userId,hashCode,type);
            service.hashCharge(request).enqueue(new NetCallBack<BaseResponce>() {
                @Override
                public void onSuccess(Call<BaseResponce> call, Response<BaseResponce> response) {
                    if (getView()!=null){
                        getView().getHashChargeData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });

        }
    }
    public interface IHashChargeView extends IBaseView {
        void getHashChargeData(Response<BaseResponce> response);
    }
}
